package com.tanhua.sso.controller;

import com.tanhua.sso.service.UserInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@RestController
@RequestMapping("user")
@Slf4j
public class UserInfoController {

    @Autowired
    private UserInfoService userInfoService;

    @PostMapping("loginReginfo")
    public ResponseEntity loginReginfo(@RequestHeader("Authorization") String token, @RequestBody Map<String,String> params) {
        userInfoService.registUserInfo(token,params);
        return ResponseEntity.ok(null);
    }

    @PostMapping("loginReginfo/head")
    public ResponseEntity head(@RequestHeader("Authorization") String token, MultipartFile headPhoto) {
        log.info("headPhoto:{}",headPhoto.getOriginalFilename());
        userInfoService.head(token,headPhoto);
        return ResponseEntity.ok(null);
    }
}
